from mmcls.apis import inference_model , init_model,show_result_pyplot
import mmcv


# 指明配置文件和权重参数文件的路劲
configs_files = 'configs/mobilenet_v2/mobilenet_v2_b32x8_imagenet.py'
checkpoint_file = 'checkpoints/mobilenet_v2_batch256_imagenet_20200708-3b2dc3af.pth'
model = init_model(configs_files, checkpoint_file, device='cuda:0')


# 推理并展示结果
img = 'demo/dog.jpg'
img_array = mmcv.imread(img)
result = inference_model(model, img_array)

show_result_pyplot(model, img, result)
